package com.allwees.bs.c.module.user.entity;

import com.allwees.bs.c.module.ops.entity.PromoActiveDefEntity;
import com.allwees.bs.core.model.coupon.constant.EPromoUseType;
import com.allwees.bs.core.modelbase.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;

@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@ToString
@Entity
@Table(name = "usr_promo_log")
public class UserPromoLogEntity extends BaseEntity {

    public UserPromoLogEntity(String userUuid, String promoCode, String promoCodeUserUuid, PromoActiveDefEntity promoActiveDef) {
        this.userUuid = userUuid;
        this.promoCode = promoCode;
        this.promoCodeUserUuid = promoCodeUserUuid;
        this.value = promoActiveDef.getValue();
        this.valueText = promoActiveDef.getValueText();
        this.maxDeductAmt = promoActiveDef.getMaxDeductAmt();
        this.name = promoActiveDef.getName();
    }

    /**
     * user uuid
     **/
    private String userUuid;

    /**
     * promo code
     **/
    private String promoCode;

    /**
     * promo code user uuid
     **/
    private String promoCodeUserUuid;

    /**
     * use type
     */
    private EPromoUseType useType;

    /**
     * value
     **/
    private BigDecimal value;

    /**
     * value text
     */
    private String valueText;

    /**
     * max deduct amt
     **/
    private BigDecimal maxDeductAmt;

    /**
     * name
     **/
    @Column
    private String name;
}
